/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    int maxDepth(TreeNode * root) {
        return DEPTH(root);
    }
    
private:
    static int DEPTH(TreeNode *  );
};


int Solution::DEPTH(TreeNode * bt){
    int dep = 0;
    int tmp = 0;
    
    if (bt == nullptr) 
        return dep;
    
    tmp = DEPTH(bt->left) ;
    
    dep = dep > tmp ? dep : tmp;
    
    tmp = DEPTH(bt->right) ;
    
    dep = dep > tmp ? dep : tmp;
    
    dep++;
    
    return dep;
    
}